function* foo(x) {
    var y = 2 * (yield (x + 1))
    var z = yield (y / 3)
    return x + y + z
}

let g = foo(1)
console.log(g.next()) //{value:2;done:false}
console.log(g.next()) //{value:NaN,done:false}
console.log(g.next()) //{value:NaN,done:true}

let f = foo(1)
console.log(f.next()) //{value:2,done:false}
console.log(f.next(2)) //{value:1.3333,done:false}
console.log(f.next(4)) //{value:9,done:false}